var app = getApp()
Page({
    data: {
        data: '',
        selected: true,
        selected1: false,
        overly: false,
        mask: false,
        dellid: '',
        mask1: false,
        code: ''

    },
    // 活动
    selected: function(e) {
        this.setData({
            selected1: false,
            selected: true,
            mask: false
        })
        this.active()

    },
    // 藏品
    selected1: function(e) {
        var type = e.target.dataset.type;
        this.setData({
            selected: false,
            selected1: true,
        })
        this.myfocusgoods()
    },

    focemask: function(e) {
        var id = e.target.id;
        var type = e.target.dataset.type;
        this.setData({
            mask: true,
            overly: true,
            dellid: id
        })
    },
    focemask1: function(e) {
        var id = e.target.id;
        var type = e.target.dataset.type;
        this.setData({
            mask1: true,
            overly: true,
            dellid: id
        })
    },
    // 取消关注的活动
    myfocusauction_cancel: function(e) {
        var that = this;
        wx.getStorage({
            key: 'user',
            success: function(res) {
                wx.request({
                    url: app.url.requestUrl + '/focus/auctioncancel',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                        id: parseInt(that.data.dellid),
                    },
                    success: function(res) {
                        if (res.data.code == 1) {
                            that.setData({
                                mask: false,
                                overly: false,
                            })
                            wx.showToast({
                                title: res.data.msg,
                                icon: '',
                                duration: 2000,
                                mask: true
                            })
                            that.onLoad()
                        }

                    }
                })
            }
        })
    },
    // 取消关注的藏品
    myfocusgoods_cancel: function(e) {
        var that = this;
        wx.getStorage({
            key: 'user',
            success: function(res) {
                wx.request({
                    url: app.url.requestUrl + '/focus/goodscancel',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                        id: parseInt(that.data.dellid),
                    },
                    success: function(res) {
                        if (res.data.code == 1) {
                            that.setData({
                                mask1: false,
                                overly: false,
                            })
                            wx.showToast({
                                title: res.data.msg,
                                icon: '',
                                duration: 2000,
                                mask: true
                            })
                            that.onLoad()
                        }

                    }
                })
            }
        })
    },
    lose: function(e) {
        this.setData({
            mask: false,
            overly: false,
        })
    },
    // 活动
    active() {
        var that = this;
        wx.getStorage({
            key: 'user',
            success: function(res) {
                wx.request({
                    url: app.url.requestUrl + '/focus/myfocusauction',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                        page: 1
                    },
                    success: function(res) {
                        if (res.data.code == 1) {
                            that.setData({
                                data: res.data.data.data,
                                code: res.data.code
                            })
                        } else {

                        }

                    }
                })
            },
        })
    },
    // 藏品
    myfocusgoods() {
        var that = this;
        wx.getStorage({
            key: 'user',
            success: function(res) {
                wx.request({
                    url: app.url.requestUrl + '/focus/myfocusgoods',
                    method: 'POST',
                    data: {
                        openid: res.data.openid,
                        token: res.data.token,
                        page: 1
                    },
                    success: function(res) {
                        if (res.data.code == 1) {
                            that.setData({
                                data: res.data.data.data,
                                code: res.data.code
                            })
                        }

                    }
                })
            },
        })
    },
    onLoad: function(options) {
        this.active()
    }



})